package com.xhh.fs.service;

import com.xhh.fs.dao.UserDao;
import com.xhh.fs.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    UserDao userDao;

    //根据username查询
    public User getByName(String username){
        return userDao.findByUsername(username);
    }
    //根据username和password查询
    public User getByNAP(String username,String password){
        return userDao.getByUsernameAndPassword(username,password);
    }
    //判断用户是否存在
    public boolean isExist(String username){
        User user = getByName(username);
        return user != null;
    }
    //保存更新
    public void add(User user){
        userDao.save(user);
    }
}
